home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 2.iso / dist / fw_gimp.idb / usr / freeware / share / gimp / 1.2 / scripts / font-map.scm.z / font-map.scm
Text File  |  2002-07-08  |  2KB  |  74 lines

  1. ;; font-select
  2. ;; Spencer Kimball
  3.  
  4. (define (max-font-width font-list font-size)
  5.   (let* ((list font-list)
  6.      (width 0)
  7.      (maxwidth 0)
  8.      (font "")
  9.      (extents '()))
  10.     (while list
  11.        (set! font (car list))
  12.        (set! list (cdr list))
  13.        (set! extents (gimp-text-get-extents font font-size PIXELS
  14.                         "*" font "*" "*" "*" "*" "*" "*"))
  15.        (set! width (nth 0 extents))
  16.        (if (> width maxwidth) (set! maxwidth width)))
  17.     maxwidth))
  18.  
  19.  
  20. (define (max-font-height font-list font-size)
  21.   (let* ((list font-list)
  22.      (height 0)
  23.      (maxheight 0)
  24.      (font "")
  25.      (extents '()))
  26.     (while list
  27.        (set! font (car list))
  28.        (set! list (cdr list))
  29.        (set! extents (gimp-text-get-extents font font-size PIXELS
  30.                         "*" font "*" "*" "*" "*" "*" "*"))
  31.        (set! height (nth 1 extents))
  32.        (if (> height maxheight) (set! maxheight height)))
  33.     maxheight))
  34.  
  35.  
  36. (define (script-fu-font-map font-list font-size border)
  37.   (let* ((font "")
  38.      (count 0)
  39.      (text-fs 0)
  40.      (num-fonts (length font-list))
  41.      (maxheight (max-font-height font-list font-size))
  42.      (maxwidth (max-font-width font-list font-size))
  43.      (width (+ maxwidth (* 2 border)))
  44.      (height (+ (* maxheight num-fonts) (* 2 border)))
  45.      (img (car (gimp-image-new width height GRAY)))
  46.      (drawable (car (gimp-layer-new img width height GRAY_IMAGE
  47.                     "Font List" 100 NORMAL))))
  48.     (gimp-image-undo-disable img)
  49.     (gimp-image-add-layer img drawable 0)
  50.     (gimp-edit-fill drawable BG-IMAGE-FILL)
  51.  
  52.     (while font-list
  53.        (set! font (car font-list))
  54.        (set! font-list (cdr font-list))
  55.        (set! text-fs (car (gimp-text img drawable border (+ border (* count maxheight))
  56.                      font 0 TRUE font-size PIXELS "*" font "*" "*" "*" "*" "*" "*")))
  57.        (set! count (+ count 1))
  58.        (gimp-floating-sel-anchor text-fs))
  59.  
  60.     (gimp-image-undo-enable img)
  61.     (gimp-display-new img)))
  62.  
  63. (script-fu-register "script-fu-font-map"
  64.             _"<Toolbox>/Xtns/Script-Fu/Utils/Font Map..."
  65.             "Generate a listing of the specified fonts"
  66.             "Spencer Kimball"
  67.             "Spencer Kimball"
  68.             "1997"
  69.             ""
  70.             SF-VALUE _"Fonts" "'(\"Agate\" \"AlfredDrake\" \"Becker\" \"Blippo\" \"Bodoni\" \"Dragonwick\" \"Engraver\" \"Futura_Poster\" \"RoostHeavy\")"
  71.             SF-ADJUSTMENT _"Font Size (pixels)" '(32 2 1000 1 10 0 1)
  72.             SF-ADJUSTMENT _"Border" '(10 0 150 1 10 0 1)
  73. )
  74.